package org.argetr.resim.ui.component.filter;

import org.argetr.resim.proc.filter.EdgePR;
import org.argetr.resim.property.ComboBoxPRP;
import org.argetr.resim.ui.model.ComponentItem;

public class EdgeCI extends ComponentItem {

	private static final long serialVersionUID = 1;
	private static final String MASK_PROP = "EdgeCI._mask";	
	private static final String MASK_LIST[]=new String[]{"Sobel","Robert","Prewitt","Frei and Chen"};

	private int _mask;
	
	public EdgeCI()
	{		
		super();
		_name = "Edge\nDetection";
		_description = "Edge detection based one of Sobel, Robert, " +
				"Prewitt or Frei and Chen mask";
	    initProc();
	}
	
	public void setMask(int value)
	{
		_mask = value;
	}
	
	public int getMask()
	{
		return _mask;
	}
	
	protected void initDescriptorList()
	{
		super.initDescriptorList();
		//registerProperty(this,CellValidatorFactory.INTEGER_VALIDATOR,
		//         "Mask",MASK_PROP,"getMask","setMask");
		registerProperty(new ComboBoxPRP(this,MASK_PROP, "Mask", "getMask","setMask", MASK_LIST));
	}

	@Override
	public Class<EdgeCI> getComponentClass() {
		// TODO Auto-generated method stub
		return EdgeCI.class;
	}

	@Override
	public void initProc() {
		if(_processor == null)
		{
			_processor = new EdgePR();			
		}
		_mask = ((EdgePR)_processor).getParamMask();
	}
	public void updateProc() {
		if(_processor == null)
		{
			_processor = new EdgePR();			
		}
		((EdgePR)_processor).setParameters(_mask);
		//System.out.println("current mask : "+MASK_LIST[_mask]);
	}
}